<template>
	<view class="container">
		<nav-bar title="新闻资讯" />
		<view class="press" v-if="press">
			<view class="title">{{ press.title }}</view>
			<view class="publishDate">{{ press.publishDate }}</view>
			<rich-text class="content" :nodes="press.content"></rich-text>
		</view>
	</view>
</template>

<script>
	import {
		getPressDetail
	} from '@/api/common.js'
	export default {
		data() {
			return {
				press: null
			}
		},
		onLoad(option) {
			const id = option.id;
			this.getPressDetail(id);
		},
		methods: {
			// 获取新闻资讯详情
			getPressDetail(id) {
				const _that = this;
				getPressDetail(id)
					.then((res) => {
						_that.press = res.data
					})
					.catch(() => {
						uni.showToast({
							title: '加载异常'
						})
					})
			}
		}
	}
</script>

<style lang="scss">
	.press {
		width: 92%;
		padding: 0.8em 4%;
		background-color: $uni-bg-color;

		.title {
			font-size: 1.5em;
			line-height: 1.6em;
		}

		.publishDate {
			font-size: 0.8em;
			color: $uni-text-color-grey;
			margin: 0.2em 0 0.6em;
		}

		.content {
			overflow: hidden;
			line-height: 1.6em;
		}
	}
</style>
